package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ObjectUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.MemberCardItemBean;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/**
 * Autuhor:itchen
 * Time:2019/11/14 0014  14:37
 * Description: this is 会员主页列表适配器；
 */
public class MemberCardListAdapter extends BaseQuickAdapter<MemberCardItemBean, BaseViewHolder> {


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param layoutResId The layout resource id of each item.
     * @param data        A new list is created out of this one to avoid mutable list
     */
    public MemberCardListAdapter(int layoutResId, @Nullable List<MemberCardItemBean> data) {
        super(layoutResId, data);
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper             A fully initialized helper.
     * @param memberCardItemBean The item that needs to be displayed.
     */
    @Override
    protected void convert(BaseViewHolder helper, MemberCardItemBean memberCardItemBean) {

        if (!ObjectUtils.isEmpty(memberCardItemBean)) {

            //卡券名称
            String cardName = memberCardItemBean.getCardName();

            //一句话简介 介绍的
            String cardInfo = memberCardItemBean.getCardInfo();

            //卡券的类型 数字格式的  不能用于显示文字的
            int cardType = memberCardItemBean.getCardType();
            //
            String cardTypeInfo = memberCardItemBean.getCardTypeInfo();

            //卡券的有效期
            String cardTimeExpir = memberCardItemBean.getCardTimeExpir();

            //卡券的金额
            String amount = memberCardItemBean.getAmount();

            //卡券的单位
            String cardUnit = memberCardItemBean.getCardUnit();


            //卡券的金额
            TextView textViewAmount = (TextView) helper.getView(R.id.textviewamount);
            //卡券的单位
            TextView textViewUnit = (TextView) helper.getView(R.id.textviewunit);

            //卡券的名字
            TextView textViewCardName = (TextView) helper.getView(R.id.textviewcardname);
            //卡券的一句话简介
            TextView textViewNameIntro = (TextView) helper.getView(R.id.textviewnameintro);
            //卡券的有效期
            TextView textViewTimeExpir = (TextView) helper.getView(R.id.textviewtimeexpir);
            //卡券的类型标签
            TextView textViewTagForCurrentCard = (TextView) helper.getView(R.id.textviewtagforcurrentcard);


            //filldatas
            //卡券名字
            CommUtils.setText(textViewAmount, amount);
            CommUtils.setText(textViewUnit, cardUnit);
            CommUtils.setText(textViewCardName, cardName);
            CommUtils.setText(textViewNameIntro, cardInfo);
            CommUtils.setText(textViewTimeExpir, cardTimeExpir);
            CommUtils.setText(textViewTagForCurrentCard, cardTypeInfo);


        }

    }
}
